﻿<UserControl x:Class="ModernUILogViewer.Content.ContentSearchText"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"                
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"                
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <StackPanel Margin="5, 10, 0, 0">
            <TextBlock Text="FIND TEXT" Style="{StaticResource Heading2}" />
            <TextBox Focusable="True" x:Name="searchText" Margin="{StaticResource DefaultTopMargin}" HorizontalAlignment="Left" Width="200" Text="{Binding TextFilter, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
            <CheckBox IsChecked="{Binding MatchWholeWord, Mode=TwoWay}" Content="Match whole word" Margin="{StaticResource DefaultTopMargin}"></CheckBox>
            <CheckBox IsChecked="{Binding MatchIgnoreCase, Mode=TwoWay}" Content="Ignore case" Margin="{StaticResource DefaultTopMargin}"></CheckBox>
            <StackPanel Orientation="Horizontal" Margin="{StaticResource DefaultTopMargin}">            
                <Button Content="Filter" Command="{Binding FilterLogEntries}" Width="80" HorizontalAlignment="Left" />
                <Button Content="Clear" Margin="{StaticResource DefaultLeftMargin}" Width="80" HorizontalAlignment="Left" x:Name="clearButton" />
            </StackPanel>
        </StackPanel>
    </Grid>
    
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Click" SourceObject="{Binding ElementName=clearButton}">
            <ei:ChangePropertyAction TargetObject="{Binding ElementName=searchText}" PropertyName="Text" Value="{x:Null}" />
            <i:InvokeCommandAction Command="{Binding FilterLogEntries}" />
        </i:EventTrigger>
        <ei:KeyTrigger Key="Enter" SourceObject="{Binding ElementName=searchText}">
            <i:InvokeCommandAction Command="{Binding FilterLogEntries}" />
        </ei:KeyTrigger>
    </i:Interaction.Triggers>
    
</UserControl>
